<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="model.leave_message"%>
<%@ page import="dao.LeaveDao"%>

<%
	//检查会话中是否有 "fdy" 属性
	Object fdyObj = session.getAttribute("fdy");
	if (fdyObj == null) {
	    response.sendRedirect("Login.jsp");
	    return;
	}
%>   

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>辅导员页面</title>
<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
<!-- 退出登录专用 -->
    <script type="text/javascript" src="Loginout.js"></script>
</head>

<body>

<!-- 头部 -->
<div class="header" ><br>
	<nerong>&nbsp;&nbsp;辅导员页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>
 	<%
 		List<String> idclassa = (List<String>)session.getAttribute("fdy");
 		String id = idclassa.get(0);
    
 			%>
 	<button onclick="confirmLogout('<%= id %>','fdy')">退出登录</button>
</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>辅导员可选择内容</nerong>

</th>
<tr>
<td>
<a href="../View_Msg/msgFdy.jsp">&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href = "../View_SuShe/SuSheFDY_List.jsp">&emsp;学生宿舍信息查询</a><br>
</td>
</tr>
<tr>

<td>
<a href = "../View_WeiGui/WeiGuiFDY.jsp">&emsp;宿舍违规信息查询</a><br>

</td>
</tr>

<tr>
<td>
<a href = "../View_leave/T_leave.jsp">&emsp;请假信息处理</a><br>
</td>
</tr>

</table>

</div>



<div class="context" >
<!-- 这部分是每个大功能的小功能 -->
   <h2>请假信息查询</h2>
    <table class="Alltable">
        <tr>
        	<th>班级</th>
        	<th>姓名</th>
          	<th>学号</th>
            <th>请假时间</th>
            <th>课程</th>
            <th>状态</th>
            <th>操作</th>
            
        </tr>
        <%
             
  		//获取这个老师的班级数组
  		 ArrayList<String> idclass = (ArrayList<String>)session.getAttribute("fdy");

        // 老师查询请假信息（学生id、请假时间、状态、操作）
        LeaveDao dao = new LeaveDao();
        List<leave_message> Messages = dao.getClassLeaveMessages(idclass);  
        //List<leave_message> Messages = dao.getAllLeaveMessages();
                      
         // 检查leaveMessages列表是否不为null
            if (Messages != null) {
            	// 遍历leaveMessages列表中的每个leave_message对象
                for (leave_message lm : Messages) {
        %>
            <tr>
            	<td><%= lm.getClassroom() %></td>
            	<td><%= lm.getName() %></td>
				<td><%= lm.getId() %></td>
				<td><%= lm.getSdata() %> <%= lm.getEdata() %></td>
				<td><%= lm.getCourse() %></td>
                <td><%= lm.getStatus() %></td>                
                <td><button class="btn btn-green" onclick="window.location.href='T_check.jsp?number=<%= lm.getNumber() %>'"><i class="icon-eye"></i> 查看</button></td>
            </tr>
        <%
                }
            } else {
        %>
            <tr>
                <td colspan="4">No leave messages found</td>
            </tr>
        <%
            }
        %>
    </table>
    <!-- 如果有错误信息，显示它 -->
    <%
        String error = (String) request.getAttribute("error");
        if (error != null) {
    %>
        <p style="color:red"><%= error %></p>
    <%
        }
    %>
</div>

</body>
</html>